﻿/********************************************************************
FileName    :   Bll_OS.cs
CreateTime  :   2020-09-19 03:07:29
BaseClass   :   Bll_OS
FileType    :   .cs
Author      :  minjie
*********************************************************************/


using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;

using System.Data;
namespace OS.DAL
{
    /// <summary>
    /// Dal_jbxx_spdaH的摘要说明。
    /// </summary>
    public partial class Dal_jbxx_spdaH
    {
        /// <summary> 
        /// 更新一条数据(字符串) 2016-07-13更新 
        ///   2020-04-09 更新 minjie 
        /// </summary> 
        public string UpdateStr(jbxx_spdaH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update jbxx_spdaH set ");

            if (model.DjLsh != null)
                strSql.Append(" DjLsh ='" + model.DjLsh + "',");

            if (model.DjBtZdh != null)
                strSql.Append(" DjBtZdh ='" + model.DjBtZdh + "',");

            if (model.DjFtZdh != null)
                strSql.Append(" DjFtZdh ='" + model.DjFtZdh + "',");

            if (model.DjStZdh != null)
                strSql.Append(" DjStZdh ='" + model.DjStZdh + "',");

            if (model.DjState != null)
                strSql.Append(" DjState ='" + model.DjState + "',");

            if (model.DjCount != null)
                strSql.Append(" DjCount ='" + model.DjCount + "',");

            if (model.spmc != null)
                strSql.Append(" spmc ='" + model.spmc + "',");

            if (model.tmh != null)
                strSql.Append(" tmh ='" + model.tmh + "',");

            if (model.cjhh != null)
                strSql.Append(" cjhh ='" + model.cjhh + "',");

            if (model.xlmc != null)
                strSql.Append(" xlmc ='" + model.xlmc + "',");

            if (model.xlbh != null)
                strSql.Append(" xlbh ='" + model.xlbh + "',");

            if (model.gg != null)
                strSql.Append(" gg ='" + model.gg + "',");

            if (model.dw != null)
                strSql.Append(" dw ='" + model.dw + "',");

            if (model.jj != null)
                strSql.Append(" jj ='" + model.jj + "',");

            if (model.lsj != null)
                strSql.Append(" lsj ='" + model.lsj + "',");

            if (model.pfj != null)
                strSql.Append(" pfj ='" + model.pfj + "',");

            if (model.sfty != null)
                strSql.Append(" sfty ='" + model.sfty + "',");

            if (model.ys != null)
                strSql.Append(" ys ='" + model.ys + "',");

            if (model.kcsj != null)
                strSql.Append(" kcsj ='" + model.kcsj + "',");

            if (model.kcxx != null)
                strSql.Append(" kcxx ='" + model.kcxx + "',");

            if (model.tp != null)
                strSql.Append(" tp ='" + model.tp + "',");

            if (model.bhfs != null)
                strSql.Append(" bhfs ='" + model.bhfs + "',");

            if (model.splm != null)
                strSql.Append(" splm ='" + model.splm + "',");

            if (model.spbh != null)
                strSql.Append(" spbh ='" + model.spbh + "',");

            if (model.gysbh != null)
                strSql.Append(" gysbh ='" + model.gysbh + "',");

            if (model.gysmc != null)
                strSql.Append(" gysmc ='" + model.gysmc + "',");

            if (model.gyszk != null)
                strSql.Append(" gyszk ='" + model.gyszk + "',");

            if (model.flh != null)
                strSql.Append(" flh ='" + model.flh + "',");

            if (model.flmc != null)
                strSql.Append(" flmc ='" + model.flmc + "',");

            if (model.ysbh != null)
                strSql.Append(" ysbh ='" + model.ysbh + "',");

            if (model.spjm != null)
                strSql.Append(" spjm ='" + model.spjm + "',");

            if (model.byj != null)
                strSql.Append(" byj ='" + model.byj + "',");

            if (model.bz != null)
                strSql.Append(" bz ='" + model.bz + "',");

            if (model.djyh != null)
                strSql.Append(" djyh ='" + model.djyh + "',");

            if (model.djsj != null)
                strSql.Append(" djsj ='" + model.djsj + "',");

            if (model.xgyh != null)
                strSql.Append(" xgyh ='" + model.xgyh + "',");

            if (model.xgsj != null)
                strSql.Append(" xgsj ='" + model.xgsj + "',");

            if (model.zdbm != null)
                strSql.Append(" zdbm ='" + model.zdbm + "',");

            if (model.zdtmh != null)
                strSql.Append(" zdtmh ='" + model.zdtmh + "',");

            if (model.zdzdbm != null)
                strSql.Append(" zdzdbm ='" + model.zdzdbm + "',");

            if (model.sfdz != null)
                strSql.Append(" sfdz ='" + model.sfdz + "',");

            if (model.bmbh != null)
                strSql.Append(" bmbh ='" + model.bmbh + "',");

            if (model.bmmc != null)
                strSql.Append(" bmmc ='" + model.bmmc + "',");

            if (model.dlbh != null)
                strSql.Append(" dlbh ='" + model.dlbh + "'");


            strSql.Append(" where  DjLsh ='" + model.DjLsh + "' ");
            return strSql.ToString();
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="DjLsh">主键</param>
        /// <returns></returns>
        public bool Exists(int DjLsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from jbxx_spdaH");
            strSql.Append(" where   DjLsh =@DjLsh ");
            SqlParameter[] parameters = { new SqlParameter("@DjLsh", SqlDbType.Int, 4) };
            parameters[0].Value = DjLsh;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }
        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public bool Add(jbxx_spdaH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into jbxx_spdaH (");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,spmc,tmh,cjhh,xlmc,xlbh,gg,dw,jj,lsj,pfj,sfty,ys,kcsj,kcxx,tp,bhfs,splm,spbh,gysbh,gysmc,gyszk,flh,flmc,ysbh,spjm,byj,bz,djyh,djsj,xgyh,xgsj,zdbm,zdtmh,zdzdbm,sfdz,bmbh,bmmc, dlbh) values (");
            strSql.Append("@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@spmc,@tmh,@cjhh,@xlmc,@xlbh,@gg,@dw,@jj,@lsj,@pfj,@sfty,@ys,@kcsj,@kcxx,@tp,@bhfs,@splm,@spbh,@gysbh,@gysmc,@gyszk,@flh,@flmc,@ysbh,@spjm,@byj,@bz,@djyh,@djsj,@xgyh,@xgsj,@zdbm,@zdtmh,@zdzdbm,@sfdz,@bmbh,@bmmc,@dlbh) ");
            SqlParameter[] parameters = {

            new SqlParameter("@DjLsh",SqlDbType.Int,4),

            new SqlParameter("@DjBtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjFtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjStZdh",SqlDbType.Int,4),

            new SqlParameter("@DjState",SqlDbType.Char,10),

            new SqlParameter("@DjCount",SqlDbType.Int,4),

            new SqlParameter("@spmc",SqlDbType.VarChar,50),

            new SqlParameter("@tmh",SqlDbType.VarChar,50),

            new SqlParameter("@cjhh",SqlDbType.VarChar,50),

            new SqlParameter("@xlmc",SqlDbType.VarChar,50),

            new SqlParameter("@xlbh",SqlDbType.VarChar,50),

            new SqlParameter("@gg",SqlDbType.VarChar,50),

            new SqlParameter("@dw",SqlDbType.VarChar,50),

            new SqlParameter("@jj",SqlDbType.Decimal,9),

            new SqlParameter("@lsj",SqlDbType.Decimal,9),

            new SqlParameter("@pfj",SqlDbType.Decimal,9),

            new SqlParameter("@sfty",SqlDbType.VarChar,50),

            new SqlParameter("@ys",SqlDbType.VarChar,50),

            new SqlParameter("@kcsj",SqlDbType.Decimal,9),

            new SqlParameter("@kcxx",SqlDbType.Decimal,9),

            new SqlParameter("@tp",SqlDbType.Image),

            new SqlParameter("@bhfs",SqlDbType.VarChar,50),

            new SqlParameter("@splm",SqlDbType.VarChar,50),

            new SqlParameter("@spbh",SqlDbType.VarChar,50),

            new SqlParameter("@gysbh",SqlDbType.VarChar,50),

            new SqlParameter("@gysmc",SqlDbType.VarChar,50),

            new SqlParameter("@gyszk",SqlDbType.Decimal,9),

            new SqlParameter("@flh",SqlDbType.VarChar,50),

            new SqlParameter("@flmc",SqlDbType.VarChar,50),

            new SqlParameter("@ysbh",SqlDbType.VarChar,50),

            new SqlParameter("@spjm",SqlDbType.VarChar,50),

            new SqlParameter("@byj",SqlDbType.Decimal,9),

            new SqlParameter("@bz",SqlDbType.VarChar,50),

            new SqlParameter("@djyh",SqlDbType.VarChar,50),

            new SqlParameter("@djsj",SqlDbType.DateTime),

            new SqlParameter("@xgyh",SqlDbType.VarChar,50),

            new SqlParameter("@xgsj",SqlDbType.DateTime),

            new SqlParameter("@zdbm",SqlDbType.VarChar,50),

            new SqlParameter("@zdtmh",SqlDbType.VarChar,50),

            new SqlParameter("@zdzdbm",SqlDbType.VarChar,50),

            new SqlParameter("@sfdz",SqlDbType.VarChar,50),

            new SqlParameter("@bmbh",SqlDbType.VarChar,50),

            new SqlParameter("@bmmc",SqlDbType.VarChar,50),

            new SqlParameter("@dlbh",SqlDbType.VarChar,50)
     };

            if (model.DjLsh.ToString() != null)
                parameters[0].Value = model.DjLsh;
            else
                parameters[0].Value = 0;

            if (model.DjBtZdh.ToString() != null)
                parameters[1].Value = model.DjBtZdh;
            else
                parameters[1].Value = 0;

            if (model.DjFtZdh.ToString() != null)
                parameters[2].Value = model.DjFtZdh;
            else
                parameters[2].Value = 0;

            if (model.DjStZdh.ToString() != null)
                parameters[3].Value = model.DjStZdh;
            else
                parameters[3].Value = 0;

            if (model.DjState != null)
                parameters[4].Value = model.DjState;
            else
                parameters[4].Value = DBNull.Value;


            if (model.DjCount.ToString() != null)
                parameters[5].Value = model.DjCount;
            else
                parameters[5].Value = 0;

            if (model.spmc != null)
                parameters[6].Value = model.spmc;
            else
                parameters[6].Value = DBNull.Value;


            if (model.tmh != null)
                parameters[7].Value = model.tmh;
            else
                parameters[7].Value = DBNull.Value;


            if (model.cjhh != null)
                parameters[8].Value = model.cjhh;
            else
                parameters[8].Value = DBNull.Value;


            if (model.xlmc != null)
                parameters[9].Value = model.xlmc;
            else
                parameters[9].Value = DBNull.Value;


            if (model.xlbh != null)
                parameters[10].Value = model.xlbh;
            else
                parameters[10].Value = DBNull.Value;


            if (model.gg != null)
                parameters[11].Value = model.gg;
            else
                parameters[11].Value = DBNull.Value;


            if (model.dw != null)
                parameters[12].Value = model.dw;
            else
                parameters[12].Value = DBNull.Value;


            if (model.jj.ToString() != null)
                parameters[13].Value = model.jj;
            else
                parameters[13].Value = 0;

            if (model.lsj.ToString() != null)
                parameters[14].Value = model.lsj;
            else
                parameters[14].Value = 0;

            if (model.pfj.ToString() != null)
                parameters[15].Value = model.pfj;
            else
                parameters[15].Value = 0;

            if (model.sfty != null)
                parameters[16].Value = model.sfty;
            else
                parameters[16].Value = DBNull.Value;


            if (model.ys != null)
                parameters[17].Value = model.ys;
            else
                parameters[17].Value = DBNull.Value;


            if (model.kcsj.ToString() != null)
                parameters[18].Value = model.kcsj;
            else
                parameters[18].Value = 0;

            if (model.kcxx.ToString() != null)
                parameters[19].Value = model.kcxx;
            else
                parameters[19].Value = 0;

            if (model.tp != null)
                parameters[20].Value = model.tp;
            else
                parameters[20].Value = DBNull.Value;


            if (model.bhfs != null)
                parameters[21].Value = model.bhfs;
            else
                parameters[21].Value = DBNull.Value;


            if (model.splm != null)
                parameters[22].Value = model.splm;
            else
                parameters[22].Value = DBNull.Value;


            if (model.spbh != null)
                parameters[23].Value = model.spbh;
            else
                parameters[23].Value = DBNull.Value;


            if (model.gysbh != null)
                parameters[24].Value = model.gysbh;
            else
                parameters[24].Value = DBNull.Value;


            if (model.gysmc != null)
                parameters[25].Value = model.gysmc;
            else
                parameters[25].Value = DBNull.Value;


            if (model.gyszk.ToString() != null)
                parameters[26].Value = model.gyszk;
            else
                parameters[26].Value = 0;

            if (model.flh != null)
                parameters[27].Value = model.flh;
            else
                parameters[27].Value = DBNull.Value;


            if (model.flmc != null)
                parameters[28].Value = model.flmc;
            else
                parameters[28].Value = DBNull.Value;


            if (model.ysbh != null)
                parameters[29].Value = model.ysbh;
            else
                parameters[29].Value = DBNull.Value;


            if (model.spjm != null)
                parameters[30].Value = model.spjm;
            else
                parameters[30].Value = DBNull.Value;


            if (model.byj.ToString() != null)
                parameters[31].Value = model.byj;
            else
                parameters[31].Value = 0;

            if (model.bz != null)
                parameters[32].Value = model.bz;
            else
                parameters[32].Value = DBNull.Value;


            if (model.djyh != null)
                parameters[33].Value = model.djyh;
            else
                parameters[33].Value = DBNull.Value;


            if (model.djsj != null)
                parameters[34].Value = model.djsj;
            else
                parameters[34].Value = DBNull.Value;


            if (model.xgyh != null)
                parameters[35].Value = model.xgyh;
            else
                parameters[35].Value = DBNull.Value;


            if (model.xgsj != null)
                parameters[36].Value = model.xgsj;
            else
                parameters[36].Value = DBNull.Value;


            if (model.zdbm != null)
                parameters[37].Value = model.zdbm;
            else
                parameters[37].Value = DBNull.Value;


            if (model.zdtmh != null)
                parameters[38].Value = model.zdtmh;
            else
                parameters[38].Value = DBNull.Value;


            if (model.zdzdbm != null)
                parameters[39].Value = model.zdzdbm;
            else
                parameters[39].Value = DBNull.Value;


            if (model.sfdz != null)
                parameters[40].Value = model.sfdz;
            else
                parameters[40].Value = DBNull.Value;


            if (model.bmbh != null)
                parameters[41].Value = model.bmbh;
            else
                parameters[41].Value = DBNull.Value;


            if (model.bmmc != null)
                parameters[42].Value = model.bmmc;
            else
                parameters[42].Value = DBNull.Value;


            if (model.dlbh != null)
                parameters[43].Value = model.dlbh;
            else
                parameters[43].Value = DBNull.Value;


            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary> 
        /// 增加一条数据(字符串) 
        /// </summary> 
        public string AddStr(jbxx_spdaH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into jbxx_spdaH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,spmc,tmh,cjhh,xlmc,xlbh,gg,dw,jj,lsj,pfj,sfty,ys,kcsj,kcxx,tp,bhfs,splm,spbh,gysbh,gysmc,gyszk,flh,flmc,ysbh,spjm,byj,bz,djyh,djsj,xgyh,xgsj,zdbm,zdtmh,zdzdbm,sfdz,bmbh,bmmc, dlbh) values (");
            strSql.Append("'" + model.DjLsh + "','" + model.DjBtZdh + "','" + model.DjFtZdh + "','" + model.DjStZdh + "','" + model.DjState + "','" + model.DjCount + "','" + model.spmc + "','" + model.tmh + "','" + model.cjhh + "','" + model.xlmc + "','" + model.xlbh + "','" + model.gg + "','" + model.dw + "','" + model.jj + "','" + model.lsj + "','" + model.pfj + "','" + model.sfty + "','" + model.ys + "','" + model.kcsj + "','" + model.kcxx + "','" + model.tp + "','" + model.bhfs + "','" + model.splm + "','" + model.spbh + "','" + model.gysbh + "','" + model.gysmc + "','" + model.gyszk + "','" + model.flh + "','" + model.flmc + "','" + model.ysbh + "','" + model.spjm + "','" + model.byj + "','" + model.bz + "','" + model.djyh + "','" + model.djsj + "','" + model.xgyh + "','" + model.xgsj + "','" + model.zdbm + "','" + model.zdtmh + "','" + model.zdzdbm + "','" + model.sfdz + "','" + model.bmbh + "','" + model.bmmc + "','" + model.dlbh + "') ");
            return strSql.ToString();
        }
        /// <summary> 
        /// 更新一条数据 
        ///创建时间:2020-04-09
        ///创建人:minjie
        /// </summary> 
        public bool Update(jbxx_spdaH_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update jbxx_spdaH set ");
            strSql.Append(" DjLsh = @DjLsh,");

            strSql.Append(" DjBtZdh = @DjBtZdh,");

            strSql.Append(" DjFtZdh = @DjFtZdh,");

            strSql.Append(" DjStZdh = @DjStZdh,");

            strSql.Append(" DjState = @DjState,");

            strSql.Append(" DjCount = @DjCount,");

            strSql.Append(" spmc = @spmc,");

            strSql.Append(" tmh = @tmh,");

            strSql.Append(" cjhh = @cjhh,");

            strSql.Append(" xlmc = @xlmc,");

            strSql.Append(" xlbh = @xlbh,");

            strSql.Append(" gg = @gg,");

            strSql.Append(" dw = @dw,");

            strSql.Append(" jj = @jj,");

            strSql.Append(" lsj = @lsj,");

            strSql.Append(" pfj = @pfj,");

            strSql.Append(" sfty = @sfty,");

            strSql.Append(" ys = @ys,");

            strSql.Append(" kcsj = @kcsj,");

            strSql.Append(" kcxx = @kcxx,");

            strSql.Append(" tp = @tp,");

            strSql.Append(" bhfs = @bhfs,");

            strSql.Append(" splm = @splm,");

            strSql.Append(" spbh = @spbh,");

            strSql.Append(" gysbh = @gysbh,");

            strSql.Append(" gysmc = @gysmc,");

            strSql.Append(" gyszk = @gyszk,");

            strSql.Append(" flh = @flh,");

            strSql.Append(" flmc = @flmc,");

            strSql.Append(" ysbh = @ysbh,");

            strSql.Append(" spjm = @spjm,");

            strSql.Append(" byj = @byj,");

            strSql.Append(" bz = @bz,");

            strSql.Append(" djyh = @djyh,");

            strSql.Append(" djsj = @djsj,");

            strSql.Append(" xgyh = @xgyh,");

            strSql.Append(" xgsj = @xgsj,");

            strSql.Append(" zdbm = @zdbm,");

            strSql.Append(" zdtmh = @zdtmh,");

            strSql.Append(" zdzdbm = @zdzdbm,");

            strSql.Append(" sfdz = @sfdz,");

            strSql.Append(" bmbh = @bmbh,");

            strSql.Append(" bmmc = @bmmc,");

            strSql.Append(" dlbh = @dlbh");


            strSql.Append(" where  DjLsh =@DjLsh");
            SqlParameter[] parameters = {

            new SqlParameter("@DjLsh",SqlDbType.Int,4),

            new SqlParameter("@DjBtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjFtZdh",SqlDbType.Int,4),

            new SqlParameter("@DjStZdh",SqlDbType.Int,4),

            new SqlParameter("@DjState",SqlDbType.Char,10),

            new SqlParameter("@DjCount",SqlDbType.Int,4),

            new SqlParameter("@spmc",SqlDbType.VarChar,50),

            new SqlParameter("@tmh",SqlDbType.VarChar,50),

            new SqlParameter("@cjhh",SqlDbType.VarChar,50),

            new SqlParameter("@xlmc",SqlDbType.VarChar,50),

            new SqlParameter("@xlbh",SqlDbType.VarChar,50),

            new SqlParameter("@gg",SqlDbType.VarChar,50),

            new SqlParameter("@dw",SqlDbType.VarChar,50),

            new SqlParameter("@jj",SqlDbType.Decimal,9),

            new SqlParameter("@lsj",SqlDbType.Decimal,9),

            new SqlParameter("@pfj",SqlDbType.Decimal,9),

            new SqlParameter("@sfty",SqlDbType.VarChar,50),

            new SqlParameter("@ys",SqlDbType.VarChar,50),

            new SqlParameter("@kcsj",SqlDbType.Decimal,9),

            new SqlParameter("@kcxx",SqlDbType.Decimal,9),

            new SqlParameter("@tp",SqlDbType.Image),

            new SqlParameter("@bhfs",SqlDbType.VarChar,50),

            new SqlParameter("@splm",SqlDbType.VarChar,50),

            new SqlParameter("@spbh",SqlDbType.VarChar,50),

            new SqlParameter("@gysbh",SqlDbType.VarChar,50),

            new SqlParameter("@gysmc",SqlDbType.VarChar,50),

            new SqlParameter("@gyszk",SqlDbType.Decimal,9),

            new SqlParameter("@flh",SqlDbType.VarChar,50),

            new SqlParameter("@flmc",SqlDbType.VarChar,50),

            new SqlParameter("@ysbh",SqlDbType.VarChar,50),

            new SqlParameter("@spjm",SqlDbType.VarChar,50),

            new SqlParameter("@byj",SqlDbType.Decimal,9),

            new SqlParameter("@bz",SqlDbType.VarChar,50),

            new SqlParameter("@djyh",SqlDbType.VarChar,50),

            new SqlParameter("@djsj",SqlDbType.DateTime),

            new SqlParameter("@xgyh",SqlDbType.VarChar,50),

            new SqlParameter("@xgsj",SqlDbType.DateTime),

            new SqlParameter("@zdbm",SqlDbType.VarChar,50),

            new SqlParameter("@zdtmh",SqlDbType.VarChar,50),

            new SqlParameter("@zdzdbm",SqlDbType.VarChar,50),

            new SqlParameter("@sfdz",SqlDbType.VarChar,50),

            new SqlParameter("@bmbh",SqlDbType.VarChar,50),

            new SqlParameter("@bmmc",SqlDbType.VarChar,50),

            new SqlParameter("@dlbh",SqlDbType.VarChar,50)
     };

            if (model.DjLsh.ToString() != null)
                parameters[0].Value = model.DjLsh;
            else
                parameters[0].Value = 0;

            if (model.DjBtZdh.ToString() != null)
                parameters[1].Value = model.DjBtZdh;
            else
                parameters[1].Value = 0;

            if (model.DjFtZdh.ToString() != null)
                parameters[2].Value = model.DjFtZdh;
            else
                parameters[2].Value = 0;

            if (model.DjStZdh.ToString() != null)
                parameters[3].Value = model.DjStZdh;
            else
                parameters[3].Value = 0;

            if (model.DjState != null)
                parameters[4].Value = model.DjState;
            else
                parameters[4].Value = DBNull.Value;


            if (model.DjCount.ToString() != null)
                parameters[5].Value = model.DjCount;
            else
                parameters[5].Value = 0;

            if (model.spmc != null)
                parameters[6].Value = model.spmc;
            else
                parameters[6].Value = DBNull.Value;


            if (model.tmh != null)
                parameters[7].Value = model.tmh;
            else
                parameters[7].Value = DBNull.Value;


            if (model.cjhh != null)
                parameters[8].Value = model.cjhh;
            else
                parameters[8].Value = DBNull.Value;


            if (model.xlmc != null)
                parameters[9].Value = model.xlmc;
            else
                parameters[9].Value = DBNull.Value;


            if (model.xlbh != null)
                parameters[10].Value = model.xlbh;
            else
                parameters[10].Value = DBNull.Value;


            if (model.gg != null)
                parameters[11].Value = model.gg;
            else
                parameters[11].Value = DBNull.Value;


            if (model.dw != null)
                parameters[12].Value = model.dw;
            else
                parameters[12].Value = DBNull.Value;


            if (model.jj.ToString() != null)
                parameters[13].Value = model.jj;
            else
                parameters[13].Value = 0;

            if (model.lsj.ToString() != null)
                parameters[14].Value = model.lsj;
            else
                parameters[14].Value = 0;

            if (model.pfj.ToString() != null)
                parameters[15].Value = model.pfj;
            else
                parameters[15].Value = 0;

            if (model.sfty != null)
                parameters[16].Value = model.sfty;
            else
                parameters[16].Value = DBNull.Value;


            if (model.ys != null)
                parameters[17].Value = model.ys;
            else
                parameters[17].Value = DBNull.Value;


            if (model.kcsj.ToString() != null)
                parameters[18].Value = model.kcsj;
            else
                parameters[18].Value = 0;

            if (model.kcxx.ToString() != null)
                parameters[19].Value = model.kcxx;
            else
                parameters[19].Value = 0;

            if (model.tp != null)
                parameters[20].Value = model.tp;
            else
                parameters[20].Value = DBNull.Value;


            if (model.bhfs != null)
                parameters[21].Value = model.bhfs;
            else
                parameters[21].Value = DBNull.Value;


            if (model.splm != null)
                parameters[22].Value = model.splm;
            else
                parameters[22].Value = DBNull.Value;


            if (model.spbh != null)
                parameters[23].Value = model.spbh;
            else
                parameters[23].Value = DBNull.Value;


            if (model.gysbh != null)
                parameters[24].Value = model.gysbh;
            else
                parameters[24].Value = DBNull.Value;


            if (model.gysmc != null)
                parameters[25].Value = model.gysmc;
            else
                parameters[25].Value = DBNull.Value;


            if (model.gyszk.ToString() != null)
                parameters[26].Value = model.gyszk;
            else
                parameters[26].Value = 0;

            if (model.flh != null)
                parameters[27].Value = model.flh;
            else
                parameters[27].Value = DBNull.Value;


            if (model.flmc != null)
                parameters[28].Value = model.flmc;
            else
                parameters[28].Value = DBNull.Value;


            if (model.ysbh != null)
                parameters[29].Value = model.ysbh;
            else
                parameters[29].Value = DBNull.Value;


            if (model.spjm != null)
                parameters[30].Value = model.spjm;
            else
                parameters[30].Value = DBNull.Value;


            if (model.byj.ToString() != null)
                parameters[31].Value = model.byj;
            else
                parameters[31].Value = 0;

            if (model.bz != null)
                parameters[32].Value = model.bz;
            else
                parameters[32].Value = DBNull.Value;


            if (model.djyh != null)
                parameters[33].Value = model.djyh;
            else
                parameters[33].Value = DBNull.Value;


            if (model.djsj != null)
                parameters[34].Value = model.djsj;
            else
                parameters[34].Value = DBNull.Value;


            if (model.xgyh != null)
                parameters[35].Value = model.xgyh;
            else
                parameters[35].Value = DBNull.Value;


            if (model.xgsj != null)
                parameters[36].Value = model.xgsj;
            else
                parameters[36].Value = DBNull.Value;


            if (model.zdbm != null)
                parameters[37].Value = model.zdbm;
            else
                parameters[37].Value = DBNull.Value;


            if (model.zdtmh != null)
                parameters[38].Value = model.zdtmh;
            else
                parameters[38].Value = DBNull.Value;


            if (model.zdzdbm != null)
                parameters[39].Value = model.zdzdbm;
            else
                parameters[39].Value = DBNull.Value;


            if (model.sfdz != null)
                parameters[40].Value = model.sfdz;
            else
                parameters[40].Value = DBNull.Value;


            if (model.bmbh != null)
                parameters[41].Value = model.bmbh;
            else
                parameters[41].Value = DBNull.Value;


            if (model.bmmc != null)
                parameters[42].Value = model.bmmc;
            else
                parameters[42].Value = DBNull.Value;


            if (model.dlbh != null)
                parameters[43].Value = model.dlbh;
            else
                parameters[43].Value = DBNull.Value;


            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary> 
        /// 删除一条数据 
        /// </summary> 
        public bool Delete(int DjLsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from jbxx_spdaH ");
            strSql.Append(" where   DjLsh =@DjLsh ");
            SqlParameter[] parameters = { new SqlParameter("@DjLsh", SqlDbType.Int, 4) };
            parameters[0].Value = DjLsh;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary> 
        /// 批量删除一批数据 
        /// </summary> 
        public bool DeleteList(string lists)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from sys_Config ");
            strSql.Append(" where DjLsh in (" + lists + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary> 
        /// 得到一个对象实体 
        /// </summary> 
        public jbxx_spdaH_Entity GetModel(int DjLsh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1  DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,spmc,tmh,cjhh,xlmc,xlbh,gg,dw,jj,lsj,pfj,sfty,ys,kcsj,kcxx,tp,bhfs,splm,spbh,gysbh,gysmc,gyszk,flh,flmc,ysbh,spjm,byj,bz,djyh,djsj,xgyh,xgsj,zdbm,zdtmh,zdzdbm,sfdz,bmbh,bmmc, dlbh ");
            strSql.Append(" from jbxx_spdaH ");
            jbxx_spdaH_Entity model = new jbxx_spdaH_Entity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            DataTable dt = ds.Tables[0];
            return DataTableToEntity(dt);
        }

        /// <summary> 
        /// 得到一个对象实体 
        /// </summary> 
        public jbxx_spdaH_Entity GetModel(string spbh)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1  DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,spmc,tmh,cjhh,xlmc,xlbh,gg,dw,jj,lsj,pfj,sfty,ys,kcsj,kcxx,tp,bhfs,splm,spbh,gysbh,gysmc,gyszk,flh,flmc,ysbh,spjm,byj,bz,djyh,djsj,xgyh,xgsj,zdbm,zdtmh,zdzdbm,sfdz,bmbh,bmmc, dlbh ");
            strSql.Append(" from jbxx_spdaH where spbh='" + spbh + "'");
            jbxx_spdaH_Entity model = new jbxx_spdaH_Entity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            DataTable dt = ds.Tables[0];
            return DataTableToEntity(dt);
        }

        /// <summary> 
        /// 将数据集(DataTable)转换 对象 jbxx_spdaH_Entity
        /// 创建人：minjie 
        /// 创建时间:2019-02-18 02:05:58 
        /// </summary> 
        public jbxx_spdaH_Entity DataTableToEntity(DataTable dt)
        {
            jbxx_spdaH_Entity model = new jbxx_spdaH_Entity();
            if (dt != null && dt.Rows.Count > 0)
            {

                if (dt.Rows[0]["DjLsh"] != null && dt.Rows[0]["DjLsh"].ToString() != "")
                    model.DjLsh = int.Parse(dt.Rows[0]["DjLsh"].ToString());


                if (dt.Rows[0]["DjBtZdh"] != null && dt.Rows[0]["DjBtZdh"].ToString() != "")
                    model.DjBtZdh = int.Parse(dt.Rows[0]["DjBtZdh"].ToString());


                if (dt.Rows[0]["DjFtZdh"] != null && dt.Rows[0]["DjFtZdh"].ToString() != "")
                    model.DjFtZdh = int.Parse(dt.Rows[0]["DjFtZdh"].ToString());


                if (dt.Rows[0]["DjStZdh"] != null && dt.Rows[0]["DjStZdh"].ToString() != "")
                    model.DjStZdh = int.Parse(dt.Rows[0]["DjStZdh"].ToString());

                model.DjState = dt.Rows[0]["DjState"].ToString();

                if (dt.Rows[0]["DjCount"] != null && dt.Rows[0]["DjCount"].ToString() != "")
                    model.DjCount = int.Parse(dt.Rows[0]["DjCount"].ToString());

                model.spmc = dt.Rows[0]["spmc"].ToString();
                model.tmh = dt.Rows[0]["tmh"].ToString();
                model.cjhh = dt.Rows[0]["cjhh"].ToString();
                model.xlmc = dt.Rows[0]["xlmc"].ToString();
                model.xlbh = dt.Rows[0]["xlbh"].ToString();
                model.gg = dt.Rows[0]["gg"].ToString();
                model.dw = dt.Rows[0]["dw"].ToString();
                if (dt.Rows[0]["jj"] != null && dt.Rows[0]["jj"].ToString() != "")
                    model.jj = decimal.Parse(dt.Rows[0]["jj"].ToString());

                if (dt.Rows[0]["lsj"] != null && dt.Rows[0]["lsj"].ToString() != "")
                    model.lsj = decimal.Parse(dt.Rows[0]["lsj"].ToString());

                if (dt.Rows[0]["pfj"] != null && dt.Rows[0]["pfj"].ToString() != "")
                    model.pfj = decimal.Parse(dt.Rows[0]["pfj"].ToString());

                model.sfty = dt.Rows[0]["sfty"].ToString();
                model.ys = dt.Rows[0]["ys"].ToString();
                if (dt.Rows[0]["kcsj"] != null && dt.Rows[0]["kcsj"].ToString() != "")
                    model.kcsj = decimal.Parse(dt.Rows[0]["kcsj"].ToString());

                if (dt.Rows[0]["kcxx"] != null && dt.Rows[0]["kcxx"].ToString() != "")
                    model.kcxx = decimal.Parse(dt.Rows[0]["kcxx"].ToString());

                //   model.tp = dt.Rows[0]["tp"].ToString();
                if (dt.Rows[0]["tp"] != null && dt.Rows[0]["tp"].ToString() != "")
                {
                    model.tp = (byte[])dt.Rows[0]["tp"];
                }

                model.bhfs = dt.Rows[0]["bhfs"].ToString();
                model.splm = dt.Rows[0]["splm"].ToString();
                model.spbh = dt.Rows[0]["spbh"].ToString();
                model.gysbh = dt.Rows[0]["gysbh"].ToString();
                model.gysmc = dt.Rows[0]["gysmc"].ToString();
                if (dt.Rows[0]["gyszk"] != null && dt.Rows[0]["gyszk"].ToString() != "")
                    model.gyszk = decimal.Parse(dt.Rows[0]["gyszk"].ToString());

                model.flh = dt.Rows[0]["flh"].ToString();
                model.flmc = dt.Rows[0]["flmc"].ToString();
                model.ysbh = dt.Rows[0]["ysbh"].ToString();
                model.spjm = dt.Rows[0]["spjm"].ToString();
                if (dt.Rows[0]["byj"] != null && dt.Rows[0]["byj"].ToString() != "")
                    model.byj = decimal.Parse(dt.Rows[0]["byj"].ToString());

                model.bz = dt.Rows[0]["bz"].ToString();
                model.djyh = dt.Rows[0]["djyh"].ToString();
                if (dt.Rows[0]["djsj"] != null && dt.Rows[0]["djsj"].ToString() != "")
                    model.djsj = DateTime.Parse(dt.Rows[0]["djsj"].ToString());

                model.xgyh = dt.Rows[0]["xgyh"].ToString();
                if (dt.Rows[0]["xgsj"] != null && dt.Rows[0]["xgsj"].ToString() != "")
                    model.xgsj = DateTime.Parse(dt.Rows[0]["xgsj"].ToString());

                model.zdbm = dt.Rows[0]["zdbm"].ToString();
                model.zdtmh = dt.Rows[0]["zdtmh"].ToString();
                model.zdzdbm = dt.Rows[0]["zdzdbm"].ToString();
                model.sfdz = dt.Rows[0]["sfdz"].ToString();
                model.bmbh = dt.Rows[0]["bmbh"].ToString();
                model.bmmc = dt.Rows[0]["bmmc"].ToString();
                model.dlbh = dt.Rows[0]["dlbh"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }



        /// <summary> 
        /// 执行sql语句  
        /// </summary> 
        public string GetSingle(string sql)
        {
            object obj = DbHelperSQL.GetSingle(sql);
            if (obj != null)
            {
                return obj.ToString();
            }
            else
                return "";
        }
        /// <summary> 
        /// 获得记录条数 
        /// </summary> 
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) ");
            strSql.Append(" FROM jbxx_spdaH ");
            if (!string.IsNullOrEmpty(strWhere))
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj != null && obj.ToString() != "")
                return Convert.ToInt32(obj);
            else
                return 0;
        }
        /// <summary> 
        /// 批量处理  
        /// </summary> 
        public int ExecuteSqlTran(List<string> ls, ref string error)
        {
            return DbHelperSQL.ExecuteSqlTran(ls, ref error);
        }
        /// <summary> 
        /// 分页获取数据列表 
        /// </summary> 
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby))
            {
                strSql.Append("order by " + orderby);
            }
            else
            {
                strSql.Append("order by T.DjLsh desc");
            }
            strSql.Append(")AS Row, T.*  from jbxx_spdaH  T ");
            if (!string.IsNullOrEmpty(strWhere))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }
        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM jbxx_spdaH ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }
        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public int ExecuteSql(string sql)
        {
            return DbHelperSQL.ExecuteSql(sql);
        }
        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public DataTable ExecuteDt(string sql)
        {
            return DbHelperSQL.ExecuteDt(sql);
        }


    }
}
